package com.cungmua.app.model.request;

import com.cungmua.app.utils.AppUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Joiner;

import java.io.Serializable;

/**
 * Created by kelvin.nguyen on 6/16/14.
 */
public class LoginRequest extends AuthenticatedRequest implements Serializable {
    private String email;
    private String password;
    private String authType;
    private String authToken;
    private String uid;

    @JsonCreator
    public LoginRequest(@JsonProperty("DeviceId") String deviceId, @JsonProperty("Token") String token) {
        super(deviceId, token);
        setAuthType("CMC");
    }

    @Override
    public String getSign() {
        String[] ele = new String[]{getEmail(), getPassword(), getAuthType(),
                getAuthToken(), String.valueOf(getVersion()), getDeviceId(), getToken()};
        return AppUtils.MD5(Joiner.on("").skipNulls().join(ele));
    }

    @JsonProperty("Email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @JsonProperty("Password")
    public String getPassword() {

        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @JsonProperty("AuthType")
    public String getAuthType() {
        return authType;
    }

    public void setAuthType(String authType) {
        this.authType = authType;
    }

    @JsonProperty("AuthToken")
    public String getAuthToken() {
        return authToken;
    }

    public void setAuthToken(String authToken) {
        this.authToken = authToken;
    }

    @JsonProperty("Uid")
    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }
}